package com.trkj.dao.hjj;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import com.trkj.pojo.Affaircategory;

/**
 * 事务类别DAO
 * @author HJJ
 *
 */
public interface AffaircategoryDAO extends CrudRepository<Affaircategory, Long>{
	//模糊查询
			@Query("from Affaircategory a where a.affcaName like ?1")
			public List<Affaircategory> queryByName(String affcaName);
			//请假事务
			@Query("from Affaircategory a where a.affcaId=1")
			public List<Affaircategory> findalltype();
			//补班事务
			@Query("from Affaircategory a where a.affcaId=2")
			public List<Affaircategory> findalltypebuban();
			//外勤事务
			@Query("from Affaircategory a where a.affcaId=3")
			public List<Affaircategory> findalltypewaiqin();
			//调休事务
			@Query("from Affaircategory a where a.affcaId=4")
			public List<Affaircategory> findalltypetiaoxiu();
			//补卡事务
			@Query("from Affaircategory a where a.affcaId=5")
			public List<Affaircategory> findalltypebuka();
			//加班事务
			@Query("from Affaircategory a where a.affcaId=6")
			public List<Affaircategory> findalltypejiaban();
			//全部
			@Query("from Affaircategory a where a.affcaId=1 or a.affcaId=2 or a.affcaId=3 or a.affcaId=4 or a.affcaId=5 or a.affcaId=6")
			public List<Affaircategory> findalls();
			//删除
			@Transactional
			@Modifying
			@Query("delete  from Affaircategory a where a.affcaId=?1")
			public int dele(Long affcaId);
			
			@Query("from Affaircategory a")
			public List<Affaircategory> queryByPage(Pageable p);
	@Query("from Affaircategory a")
	public List<Affaircategory> affaircategoryPageQuery(Pageable p);//分页查询所有
	@Query("from Affaircategory a where affcaId=?1")
	public List<Affaircategory> affaircategoryById(Pageable p,Long affcaId);//根据id查询
	@Query("from Affaircategory a where affcaName like ?1")
	public List<Affaircategory> affaircategoryByName(Pageable p,String affcaName);//根据名字分页模糊查询
}
